package com.szcinda.controller;

import com.szcinda.controller.configuration.UserLoginToken;
import com.szcinda.service.dto.customColumns.CustomColumnsDto;
import com.szcinda.service.dto.customColumns.CustomColumnsService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("customColumns")
public class CustomColumnsController {
    private final CustomColumnsService customColumnsService;

    public CustomColumnsController(CustomColumnsService customColumnsService) {
        this.customColumnsService = customColumnsService;
    }

    @GetMapping("{userId}/{tableName}")
    public Result<List<String>> GetById(@PathVariable String userId, @PathVariable String tableName) {
        return Result.success(customColumnsService.getByUser(userId, tableName));
    }

    @UserLoginToken
    @PostMapping("modify")
    public Result<String> update(@RequestBody CustomColumnsDto updateDto) {
        customColumnsService.update(updateDto);
        return Result.success();
    }
}
